#ifndef __MOTOR_HPP__
#define __MOTOR_HPP__
#ifdef __cplusplus
extern "C"
{
#endif
#include "Prot.h"
#ifdef __cplusplus
}
#endif
#include "Time.hpp"
#include "Tools.hpp"
#include "PID.hpp"
#include "Encoder.hpp"
#include "Flash.hpp"
#include "cmath"
#ifdef AT32
#define PWM_Period 8000
#endif
#ifdef STM32
#define PWM_Period 5600
#endif
#ifdef CH32
#define PWM_Period 4800
#endif
#define _PI 3.14159265359f
#define _PI_2 1.57079632679f
#define _PI_3 1.0471975512f
#define _2PI 6.28318530718f
#define _3PI_2 4.71238898038f
#define _PI_6 0.52359877559f
#define _SQRT3 1.73205080757f

typedef struct
{
    float Ia;
    float Ib;
    float Ic;
} Current,*Current_P;

float _normalizeAngle(float angle);
void setPhaseVoltage(float Uq, float Ud, float angle_el);
void setPhashVoltage_t(float Uq, float Ud, float engle_el);
void setPwm(uint16_t Ta, uint16_t Tb, uint16_t Tc);
void SetAngle(float angle);
float GetAngle(void);
uint8_t Calibrate(uint16_t timeout);
void Setdq(float uq,float ud);
int32_t GetRawWhell(uint8_t dir);

void Start_SVM_IT(void);
void ADC_Start(void);
Current *ADC_GetValue();
#endif